<?php

class Admin_Model_DbTable_Access extends Zend_Db_Table_Abstract {

    protected $_name = 'group_resources';

    public function getAccess($idrole) {
        $resources = new Application_Model_DbTable_Resources();
        $data = $this->fetchAll('idgroup = ' . (int) $idrole);
        return $resources->getResources($data);
    }

    public function updateAccess($idgroup, $idresources, $operation) {
        if ($operation == 'delete') {
            $this->delete("idgroup = '$idgroup' and idresource = '$idresources'");
        } else {
            $data = array(
                'idgroup' => $idgroup,
                'idresource' => $idresources
            );
            $this->insert($data);
        }
    }
    
    
    public function tieneAcceso($idgroup, $idresource) {
        $row = $this->fetchAll("idgroup = '$idgroup' and idresource = '$idresource'");
        return ($row->count() > 0);
    }
    
    
    
    
    

}

?>
